package com.lanqiao.javaparkinglot.controller;

import com.lanqiao.javaparkinglot.common.CommonResult;
import com.lanqiao.javaparkinglot.entity.Store;
import com.lanqiao.javaparkinglot.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/store")
public class StoreController {
    @Autowired
    StoreService storeService;

    @GetMapping("/cha")
    public CommonResult findstore(Store store){
        List<Store> storeList=storeService.findstore();
        return CommonResult.success("商铺表查询成功",storeList);
    }

    @PostMapping("/tianjia")
    public CommonResult addstore (@RequestBody Store store){
        storeService.addstore(store);
        return CommonResult.success("商铺表添加成功");
    }

    @PutMapping("/xiugai")
    public CommonResult updatestore (@RequestBody Store store){
        storeService.updatestore(store);
        return CommonResult.success("商铺表修改成功");
    }

    @DeleteMapping("/{store_id}")
    public CommonResult  deletestore(@PathVariable Long store_id){
        storeService.deletestore(store_id);
        return CommonResult.success("删除成功");
    }

}
